<#include "../../inc/layout.html">
<@layout title="商品销售/采购汇总表" js="scm/order/rpt.js">
<style>
html{overflow:auto;}
.comboDiv{position:absolute;left:61px;}
.comboDiv div{height:30px;}
</style>
<div class="wrapper" ms-controller="view">
  <div class="mod-search cf" ms-if="nprint">
    <div class="fl">
      <ul class="ul-inline">
      	<li>
        	<label>商品:</label>
        	<input type="text" class="ui-input" style="width:150px;" ms-keyup="qryProduct(this.value)" ms-click="qryProduct(this.value)" ms-duplex="query.product_name">
		    <div class="comboDiv" style="width:260px;" ms-visible="pdctComboV">
		    	<div ms-repeat="productList" ms-click="chooseProduct(el)">{{el.billsn}}&nbsp;&nbsp;{{el.name}}</div>
		    </div>
        </li>
      	<li ms-if="query.f==1">
        	<label>来往单位:</label>
        	<input type="text" class="ui-input" autocomplete="off" style="width:150px;" ms-keyup="qryCustomer(this.value)" ms-click="qryCustomer(this.value)" ms-duplex="query.customer_name">
		    <div class="comboDiv" style="width:260px;left:297px;" ms-visible="custComboV">
		    	<div ms-repeat="customerList" ms-click="chooseCust(el)">{{el.sn}}&nbsp;&nbsp;{{el.name}}</div>
		    </div>
        </li>
      	<li ms-if="query.f==2">
        	<label>销售员:</label>
        	<input type="text" class="ui-input" autocomplete="off" style="width:150px;" ms-keyup="qryUser(this.value)" ms-click="qryUser(this.value)" ms-duplex="query.head_name">
		    <div class="comboDiv" style="width:260px;left:297px;" ms-visible="userComboV">
		    	<div ms-repeat="userList" ms-click="chooseUser(el)">{{el.realname}}-{{el.position_name}}-{{el.department_name}}</div>
		    </div>
        </li>
        <li>
          <label>日期:</label>
          <input type="text" id="beginDate" class="ui-input ui-datepicker-input" ms-duplex="query.start_date">
          <span>-</span>
          <input type="text" id="endDate" class="ui-input ui-datepicker-input"ms-duplex="query.end_date">
        </li>
        <li ms-if="query.type==0">
        <label class="ui-chk" ms-class-checked="query.m==1" ms-click="mCheck()">计算毛利</label>
        </li>
        <li>
        <label class="ui-chk" ms-class-checked="query.t==1" ms-click="tCheck()">统计退货</label>
        </li>
        <li>
        <label class="ui-chk" ms-class-checked="query.tax==1" ms-click="taxCheck()">含税</label>
        </li>
        <li>
        <a class="ui-btn mrb" ms-click="loadData" title="查询"><i class="fa fa-search"></i></a>
        </li>
      </ul>
    </div>
    <div class="fr">
    <a class="ui-btn mrb" ms-click="printRpt" title="打印"><i class="fa fa-print"></i></a>
<!--     <a class="ui-btn mrb" id="btn_down" title="导出"><i class="fa fa-download"></i></a> -->
    </div>
  </div>
  <div class="no-query" ms-if="list.length==0"></div>
  <div class="bills" ms-if="list.length>0">
    <p style="font-size:24px;text-align:center;">
    	<span  ms-if="type_==1">采购</span><span  ms-if="type_==0">销售</span>汇总表（按<soan ms-if="query.f==0">商品</soan><soan ms-if="query.f==1&&query.type==0">客户</soan><soan ms-if="query.f==1&&query.type==1">供应商</soan><soan ms-if="query.f==2">销售员</soan>）
    </p>
    <p>
    日期：{{query.start_date}}至{{query.end_date}}<span class="fr">制表人：{{user.realname}}&nbsp;&nbsp;制表日期：${(now?string('yyyy年MM月dd日'))}</span>
    </p>
	<table class="table table-bordered table-striped able-hover">
		<thead>
			<tr>
				<th>行号</th>
				<th ms-if="query.f==1&&query.type==0">客户</th>
				<th ms-if="query.f==1&&query.type==1">供应商</th>
				<th ms-if="query.f==2&&query.type==0">销售员</th>
				<th>商品编号</th>
				<th>商品名称</th>
				<th>规格型号</th>
				<th>计量单位</th>
				<th>数量</th>
				<th>单价</th>
				<th ms-if="query.type==0">销售收入</th>
				<th ms-if="query.type==1">采购支出</th>
				<th ms-if="query.m>0">单位成本</th>
				<th ms-if="query.m>0">销售成本</th>
				<th ms-if="query.m>0">销售毛利</th>
				<th ms-if="query.m>0">毛利率</th>
			</tr>
		</thead>
		<tbody>
			<tr ms-repeat="list">
				<td>{{$index+1}}</td>
				<td ms-if="el.name!='小计'&&query.f>0" >{{el.relation_name}}</td>
				<td ms-if="el.name!='小计'">{{el.sn}}</td>
				<td ms-if="el.name!='小计'">{{el.product_name}}</td>
				<td ms-if="el.name=='小计'" ms-attr-colspan="query.f>0?5:4" align="right">{{el.name}}</td>
				<td ms-if="el.name!='小计'">{{el.model}}</td>
				<td ms-if="el.name!='小计'">{{el.unit|custParame}}</td>
				<td align="right">{{el.amount}}</td>
				<td align="right">{{el.sale_price|money}}</td>
				<td align="right">{{el.amt|money}}</td>
				<td align="right" ms-if="query.m>0">{{el.purchase_price|money}}</td>
				<td align="right" ms-if="query.m>0">{{(el.cost)|money}}</td>
				<td align="right" ms-if="query.m>0">{{el.ml|money}}</td>
				<td align="right" ms-if="query.m>0">{{(el.ml/el.amt)*100|money}}%</td>
			</tr>
		</tbody>
		<tfoot>
			<tr>
				<td ms-attr-colspan="query.f>0?6:5" align="right"><b>合计</b></td>
				<td align="right">{{amount_total}}</td>
				<td align="right"></td>
				<td align="right">{{amt_total|money}}</td>
				<td align="right" ms-if="query.m>0"></td>
				<td align="right" ms-if="query.m>0">{{cost_total|money}}</td>
				<td align="right" ms-if="query.m>0">{{ml_total|money}}</td>
				<td align="right" ms-if="query.m>0">{{(ml_total/amt_total)*100|money}}%</td>
			</tr>
		</tfoot>
	</table>
  </div>
</div>
<script>
var type=${type!0},f=${f!0};</script>
</@layout>